package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.IChartData;
import cn.limc.ohoscharts.entity.IStickEntity;
import cn.limc.ohoscharts.entity.ListChartData;
import cn.limc.ohoscharts.entity.StickEntity;
import cn.limc.ohoscharts.event.IZoomable;
import cn.limc.ohoscharts.view.SlipMinusStickChart;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

import java.util.ArrayList;
import java.util.List;

public class SlipMinusStickChartAbility extends BaseAbility {

  SlipMinusStickChart slipminusstickchart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_ability_slip_minus_stick_chart);
    initSlipMinusStickChart();
  }


  //    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.slip_minus_stick_chart, menu);
//        return true;
//    }

  private void initSlipMinusStickChart() {
    this.slipminusstickchart =
            (SlipMinusStickChart) findComponentById(ResourceTable.Id_slipminusstickchart);

    List<IStickEntity> data = new ArrayList<IStickEntity>();
    data.add(new StickEntity(50000, 0, 20110603));
    data.add(new StickEntity(42000, 0, 20110703));
    data.add(new StickEntity(32000, 0, 20110803));
    data.add(new StickEntity(21000, 0, 20110903));
    data.add(new StickEntity(0, -12000, 20111003));
    data.add(new StickEntity(0, -28000, 20111103));
    data.add(new StickEntity(0, -41000, 20111203));
    data.add(new StickEntity(0, -25000, 20120103));
    data.add(new StickEntity(0, -18000, 20120203));
    data.add(new StickEntity(14000, 0, 20120303));
    data.add(new StickEntity(24000, 0, 20120303));
    data.add(new StickEntity(36000, 0, 20120303));
    data.add(new StickEntity(46000, 0, 20120303));
    data.add(new StickEntity(50000, 0, 20110603));
    data.add(new StickEntity(42000, 0, 20110703));
    data.add(new StickEntity(32000, 0, 20110803));
    data.add(new StickEntity(21000, 0, 20110903));
    data.add(new StickEntity(0, -12000, 20111003));
    data.add(new StickEntity(0, -28000, 20111103));
    data.add(new StickEntity(0, -41000, 20111203));
    data.add(new StickEntity(0, -25000, 20120103));
    data.add(new StickEntity(0, -18000, 20120203));
    data.add(new StickEntity(14000, 0, 20120303));
    data.add(new StickEntity(24000, 0, 20120303));
    data.add(new StickEntity(36000, 0, 20120303));
    data.add(new StickEntity(46000, 0, 20120303));
    data.add(new StickEntity(50000, 0, 20110603));
    data.add(new StickEntity(42000, 0, 20110703));
    data.add(new StickEntity(32000, 0, 20110803));
    data.add(new StickEntity(21000, 0, 20110903));
    data.add(new StickEntity(0, -12000, 20111003));
    data.add(new StickEntity(0, -28000, 20111103));
    data.add(new StickEntity(0, -41000, 20111203));
    data.add(new StickEntity(0, -25000, 20120103));
    data.add(new StickEntity(0, -18000, 20120203));
    data.add(new StickEntity(14000, 0, 20120303));
    data.add(new StickEntity(24000, 0, 20120303));
    data.add(new StickEntity(36000, 0, 20120303));
    data.add(new StickEntity(46000, 0, 20120303));

    slipminusstickchart.setMaxValue(50000);
    slipminusstickchart.setMinValue(-50000);

    slipminusstickchart.setBorderColor(Color.GRAY.getValue());
    slipminusstickchart.setAxisXColor(Color.WHITE.getValue());
    slipminusstickchart.setAxisYColor(Color.WHITE.getValue());
    slipminusstickchart.setLatitudeFontColor(Color.WHITE.getValue());
    slipminusstickchart.setLatitudeColor(Color.GRAY.getValue());
    slipminusstickchart.setLongitudeFontColor(Color.WHITE.getValue());
    slipminusstickchart.setLongitudeColor(Color.GRAY.getValue());
    // 最大纬线数
    slipminusstickchart.setLatitudeNum(3);
    // 最大经线数
    slipminusstickchart.setLongitudeNum(2);
    slipminusstickchart.setDisplayFrom(0);
    slipminusstickchart.setDisplayNumber(10);
    slipminusstickchart.setMinDisplayNumber(5);

    slipminusstickchart.setZoomBaseLine(IZoomable.ZOOM_BASE_LINE_CENTER);
    slipminusstickchart.setDisplayLongitudeTitle(true);
    slipminusstickchart.setDisplayLatitudeTitle(true);
    // slipminusstickchart.setDisplayCrossXOnTouch(false);
    // slipminusstickchart.setDisplayCrossYOnTouch(false);
    slipminusstickchart.setDisplayLatitude(true);
    slipminusstickchart.setDisplayLongitude(true);
    slipminusstickchart.setStickSpacing(10);

    slipminusstickchart.setDataQuadrantPaddingTop(5);
    slipminusstickchart.setDataQuadrantPaddingBottom(5);
    slipminusstickchart.setDataQuadrantPaddingLeft(5);
    slipminusstickchart.setDataQuadrantPaddingRight(5);
    // slipminusstickchart.setAxisYTitleQuadrantWidth(50);
    // slipminusstickchart.setAxisXTitleQuadrantHeight(20);
    slipminusstickchart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    slipminusstickchart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

    IChartData<IStickEntity> datas = new ListChartData<IStickEntity>(data);
    slipminusstickchart.setStickData(datas);
  }

}
